<template>
	<view class="wrap">
		<view class="title">报名信息</view>
		<view class="content">
			<view class="content_name">
				姓名
				<text style="color: #009B01;">*</text>
				<u--input v-model="form.userName" placeholder="请输入姓名" inputAlign="right" border="none"></u--input>
			</view>

			<view class="content_name">
				手机号
				<text style="color: #009B01;">*</text>
				<u--input v-model="form.phone" placeholder="请输入手机号" inputAlign="right" border="none"></u--input>
			</view>
		</view>

		<view class="submmitBtn" @click="commitApplyInfo">
			提交报名
		</view>
		<u-toast ref="uToast"></u-toast>
	</view>
</template>

<script>
	import {collectOrder} from '../../common/api.js'

export default {
	name: 'apply-popup',
	data() {
		return {
			show: false,
			form: {
				userName: '',
				phone: this.$store.state.user.userInfo.phone
			}
		};
	},
	props: {
		bizNo: {
			type: String,
			default: ''
		}
	},
	methods: {
		commitApplyInfo() {
			console.log(uni.$u.test);
			if(uni.$u.test.isEmpty(this.form.userName)){
				uni.showToast({
					icon:'none',
					title:'请输入姓名'
				})
				return;
			}else if(!uni.$u.test.mobile(this.form.phone)) {
				uni.showToast({
					icon:'none',
					title:'请输入正确的手机号'
				})
				return;
			}else {
				collectOrder({
					bizNo : this.bizNo,
					memberNo : this.$store.state.user.userInfo.customerId,
					customersBooking : this.form.userName,
					customersBookingPhone : this.form.phone
				}).then(res => {
					uni.showToast({
						icon:'none',
						title:'报名成功'
					})
					this.$emit('applySuccess')
					uni.$emit('refreshActivityData')
				})
			}
		}
	}
};
</script>

<style lang="scss" scoped>
.wrap {
	width: 750upx;
	height: 430upx;
	// padding: 0 30upx;
	.title {
		margin-left: 40upx;
		margin-top: 85upx;
		font-size: 34upx;
		font-family: PingFang SC, PingFang SC-Bold;
		font-weight: bold;
		color: #333;
	}
	.content {
		margin: 40upx;
		&_name {
			display: flex;
			align-items: center;
			margin-top: 20upx;
			height: 50upx;
		}
	}
}

.submmitBtn {
	color: #fff;
	background-color: #009B01;
	border-radius: 14upx;
	box-shadow: 0px -1px 0px NaNpx rgba(255,129,111,0.21);
	font-size: 32upx;
	font-family: PingFang SC, PingFang SC-Bold;
	font-weight: bold;
	margin: auto 25upx;
	margin-top: 60upx;
	height: 96upx;
	display: flex;
	justify-content: center;
	align-items: center;
}
</style>
